package com.wva.common.exception;

import com.wva.common.status.Status;
import com.wva.common.status.StatusImpl;
import com.wva.common.utils.R;
import lombok.Getter;
import lombok.Setter;


@Getter
@Setter
public class BaseException extends RuntimeException {
    private Status status;

    /**
     * 抛出一个应用异常
     * @param status 状态信息
     */
    public BaseException(Status status) {
        super(status.getMessage());
        this.status = status;
    }

    public BaseException(Status status, String message) {
        super(status.getMessage());
        this.status = new StatusImpl(status.getCode(), message);
    }

    public BaseException(String message) {
        super(message);
        this.status = new StatusImpl(1, message);
    }

    public <T> BaseException(R<T> result) {
        super(result.getMessage());
        this.status = result;
    }
}
